package com.example.armmvvm.ui.media

import android.os.Bundle
import com.example.arm.base.BaseActivity
import com.example.armmvvm.databinding.ActivityMediaPlayBinding
import com.example.armmvvm.ui.media.util.AudioPlayController
import com.example.armmvvm.ui.media.util.Utils

class AudioPlayerActivity : BaseActivity<ActivityMediaPlayBinding>() {
    override fun initView(savedInstanceState: Bundle?): ActivityMediaPlayBinding {
        return ActivityMediaPlayBinding.inflate(layoutInflater)
    }

    override fun initData(savedInstanceState: Bundle?) {
        val filePath = externalCacheDir?.absolutePath
        Utils.doCopy(this, "audio", filePath)

        binding.tvPlay.setOnClickListener {
            val path = "$filePath/audioTest.mp3"
            AudioPlayController.playLocalMusic(path)
        }
        binding.tvPlayLocal.setOnClickListener {
            val path = "$filePath/audioTest2.mp3"
            AudioPlayController.playLocalMusic(path)
        }
        binding.tvStop.setOnClickListener {
            AudioPlayController.stopMusic()
        }
    }
}